/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年9月12日
 */
package com.massyframework.beanskin.assembly;

/**
 * 支持{@link AssemblyContextAware}的抽象类
 * @author huangkh
 *
 */
public abstract class AssemblyContextSupport implements AssemblyContextAware {

	private AssemblyContext context;
	
	/**
	 * 
	 */
	public AssemblyContextSupport() {
		
	}
	
	/**
	 * 装配件上下文
	 * @return {@link AssemblyContext}
	 */
	public AssemblyContext getAssemblyContext() {
		return this.context;
	}

	@Override
	public void setAssemblyContext(AssemblyContext context) {
		if (this.context != context) {
			if (this.context != null) {
				this.unbindAssemblyContext(this.context);
			}
			
			this.context = context;
			
			if (this.context != null) {
				this.bindAssemblyContext(this.context);
			}
		}
	}
	
	/**
	 * 绑定装配件上下文
	 * @param context {@link AssemblyContext}
	 */
	protected void bindAssemblyContext(AssemblyContext context) {
		
	}

	/**
	 * 取消绑定装配件上下文
	 * @param context
	 */
	protected void unbindAssemblyContext(AssemblyContext context) {
		
	}
	
	

}
